<?php $this->load->view('layout/jingqu/header');?>
<div class="order-page screen-width clearfix">
    <div class="order-left">
        <?php $this->load->view('layout/jingqu/leftmenu');?>
    </div>
    <div class="order-right">
        <div class="your-choice">
            <h5>
                <a href="<?php echo site_url('customer/accountRecord');?>">账户信息</a>
                <span>></span>申请结算
            </h5>
            <div class="sale-search gain-difference clearfix">
                <form class="rebate-validate-form form-horizontal" action="<?php echo site_url('accountinfo/rebateDo') ?>" method="post">
                    <table class="sale-table uesr-table table">
                        <tbody>
                            <tr>
                                <td>
                                    <h6>打款金额</h6>
                                    <div class="sale-inpan">
                                        <input type="hidden" name="oval" value="<?php echo abs($userAccount->amount_month)?>"/>
                                        <input type="text" name="o_income" value="<?php echo abs($userAccount->amount_month)?>" class="required number priceValid" placeholder="返利金额">
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h6>抵扣余额</h6>
                                    <div class="sale-inpan">
                                        <input type="text" name="deduction" value="<?php echo (abs($userAccount->amount_month)<abs($userAccount->amount_carry)) ? abs($userAccount->amount_month) : abs($userAccount->amount_carry);?>" class="required number priceValid" placeholder="抵扣余额">
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h6>打款单位</h6>
                                    <div class="sale-inpan">
                                       <input type="text" name="name" class="required"/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h6>联系方式</h6>
                                    <div class="sale-inpan">
                                       <input type="text" name="contact" class="mobile required"/>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <h6>实际打款</h6>
                                    <div class="sale-inpan get-reb">
                                       <i>¥</i>
                                       <span id="r_income" class="get-money">0</span>
                                    </div>
                                </td>
                            </tr>
                        <tbody>
                    </table>
                    <div class="comment-press-button clearfix">
                        <button type="submit" class="btn-com button-submit">确认结算</button>
                        <a href="<?php echo site_url('customer/accountRecord');?>" class="btn-com button-reset">返回</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('layout/jingqu/footer');?>
<script type="text/javascript"> 
$(document).ready(function(){
    jQuery.validator.addMethod('priceValid', function(value, element) {
        var priceValid  = true;
        var o_income  = parseFloat($('input[name=o_income]').val());
        var deduction = parseFloat($('input[name=deduction]').val());
        var in_income = o_income-deduction;
        if ((o_income < deduction) || o_income <= 0 || deduction <= 0) {
            priceValid = false;
        } else {
            $('#r_income').text(in_income.toFixed(2));
        }
        return this.optional(element) || priceValid;
    }, '打款金额必须大于抵扣金额，并且金额需大于零');
    
    $('.rebate-validate-form').validate();
});
</script>